package thread;

public class J_ThreadRunnable implements Runnable {

    private int m_threadID;

    public J_ThreadRunnable(int i) {
        m_threadID = i;
        System.out.println("create thread " + m_threadID);
    }

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.println("run thread " + m_threadID);
            try {
                Thread.sleep((int) (Math.random() * 1000));
            } catch (InterruptedException e) {
                System.err.println("thread error " + e);
                e.printStackTrace();
            }
        }
    }

    public static void main(String args[]) {
        System.out.println("main start");
        Thread thread1 = new Thread(new J_ThreadRunnable(1));
        Thread thread2 = new Thread(new J_ThreadRunnable(2));
        thread1.start();
        thread2.start();
        System.out.println("main end");
    }
}
